* Wealth index calculation. Keith Purvis, 03/18/2018. Jordan DHS 2017-18. cd 'C:\JO71\Wealth'. include file='wealth_assets.sps'. execute. set tvars=both. * Macro definitions to perform some recoding automatically. * Note: Do not use an asterisk in front of a macro name to try to comment it out - it will run any way because of the way the macros are expanded. * Delete the line instead or change the spelling of the macro in the comment. * Do not use the names of macros in comments - they will also be expanded too, and likely will fail. *{Create binary variables based on condition and give label }. define dichotomize( !positional !enclose('(',')') / !positional !tokens(1) / !positional !tokens(1) ) compute !2=0. if (!1) !2=1. variable labels !2 !3. value labels !2 0 'No' 1 'Yes'. formats !2 (f1.0). !enddefine. *(Separate shared toilets from non-shared toilets). define shared_fac( !positional !tokens(1) / !positional !tokens(1) / !positional !tokens(1) ). compute !2 = 0. do if (QH110=1). + if (!1=1) !2 = 1. + compute !1 = 0. end if. variable labels !2 !3. value labels !2 0 'No' 1 'Yes'. formats !2 (f1.0). !enddefine. *{Reset missing values to 'does not have', change 2 code to 0}. define no2zero( !positional !tokens(1) ) if (missing(!1) | !1<>1) !1=0. value labels !1 0 'No' 1 'Yes'. !enddefine. *{Construct Variables}. * Type of housing unit. dichotomize (QH100=1) QH100_1 "Type of housing unit: APARTMENT". dichotomize (QH100=2) QH100_2 "Type of housing unit: DAR". dichotomize (QH100=3) QH100_3 "Type of housing unit: VILLA". dichotomize (QH100=4) QH100_4 "Type of housing unit: HUT/BARRACK". dichotomize (QH100=5) QH100_5 "Type of housing unit: Mobile structure, tent". dichotomize (QH100=6) QH100_6 "Type of housing unit: OTHER". * Source of drinking water. dichotomize (QH101=11) QH101_11 "Source of drinking water: PIPED INTO HOUSING UNIT". dichotomize (QH101=12) QH101_12 "Source of drinking water: PIPED TO YARD/PLOT". dichotomize (QH101=21) QH101_21 "Source of drinking water: SPRING". dichotomize (QH101=31) QH101_31 "Source of drinking water: RAINWATER". dichotomize (QH101=41) QH101_41 "Source of drinking water: TANKER TRUCK". dichotomize (QH101=51) QH101_51 "Source of drinking water: BOTTLED WATER". dichotomize (QH101=96) QH101_96 "Source of drinking water: OTHER (SPECIFY)". * Type of toilet facility. dichotomize (QH109=11) QH109_11 "Type of toilet facility: Flush to piped sewer system". dichotomize (QH109=12) QH109_12 "Type of toilet facility: Flush to pit latrine". dichotomize (QH109=13) QH109_13 "Type of toilet facility: Flush to somewhere else". dichotomize (QH109=21) QH109_21 "Type of toilet facility: Pit latrine Ventilated Improved Pit latrine". dichotomize (QH109=22) QH109_22 "Type of toilet facility: Pit latrine with slab". dichotomize (QH109=23) QH109_23 "Type of toilet facility: Pit latrine without slab/open pit". dichotomize (QH109=61) QH109_61 "Type of toilet facility: NO FACILITY". dichotomize (QH109=96) QH109_96 "Type of toilet facility: OTHER (SPECIFY)". * Type of cooking fuel. dichotomize (QH113=1) QH113_1 "Type of cooking fuel: ELECTRICITY". dichotomize (QH113=2) QH113_2 "Type of cooking fuel: NATURAL GAS". dichotomize (QH113=3) QH113_3 "Type of cooking fuel: KEROSENE". dichotomize (QH113=4) QH113_4 "Type of cooking fuel: COAL, WOOD". dichotomize (QH113=95) QH113_95 "Type of cooking fuel: NO FOOD COOKED IN HOUSEHOLD". dichotomize (QH113=96) QH113_96 "Type of cooking fuel: OTHER (SPECIFY)". * Has independent bathroom. no2zero QH115A. * Radio. no2zero QH121A. * Television. no2zero QH121B. * Satellite. no2zero QH121C. * Telephone (non-mobile). no2zero QH121D. * Refrigerator. no2zero QH121E. * Freezer. no2zero QH121F. * Washing Machine. no2zero QH121G. * Dish Washer. no2zero QH121H. * Solar heater. no2zero QH121I. * Air conditioner. no2zero QH121J. * Fan. no2zero QH121K. * Water cooler. no2zero QH121L. * Microwave. no2zero QH121M. * Digital camera. no2zero QH121N. * Has internet access at home. no2zero QH122D. * Bank account. no2zero QH123. * Credit card. no2zero QH123A. * Main floor material. dichotomize (QH142=11) QH142_11 "Main floor material: Earth/sand". dichotomize (QH142=31) QH142_31 "Main floor material: Parquet or polished wood". dichotomize (QH142=32) QH142_32 "Main floor material: Tiles". dichotomize (QH142=33) QH142_33 "Main floor material: Marble/ceramic tiles". dichotomize (QH142=34) QH142_34 "Main floor material: Cement". dichotomize (QH142=96) QH142_96 "Main floor material: OTHER (SPECIFY)". * Main roof material. dichotomize (QH143=21) QH143_21 "Main roof material: Mud bricks". dichotomize (QH143=22) QH143_22 "Main roof material: Mud bricks with stones". dichotomize (QH143=31) QH143_31 "Main roof material: Concrete". dichotomize (QH143=32) QH143_32 "Main roof material: Zinc/metal". dichotomize (QH143=96) QH143_96 "Main roof material: OTHER (SPECIFY)". * Main wall material. dichotomize (QH144=21) QH144_21 "Main wall material: MUD BRICKS". dichotomize (QH144=22) QH144_22 "Main wall material: MUD BRICKS WITH STONES". dichotomize (QH144=31) QH144_31 "Main wall material: CEMENT BRICKS". dichotomize (QH144=32) QH144_32 "Main wall material: CUT STONES". dichotomize (QH144=33) QH144_33 "Main wall material: CUT STONE AND CONCRETE". dichotomize (QH144=34) QH144_34 "Main wall material: CONCRETE". dichotomize (QH144=35) QH144_35 "Main wall material: Zinc/metal". dichotomize (QH144=96) QH144_96 "Main wall material: OTHER". *{Members per sleeping room}. if (hhusual=0) hhusual=hhslept. if (QH116>0) memsleep=trunc(hhusual/QH116). if (QH116=0) memsleep=hhusual. if (missing(QH116) or QH116>=99 or memsleep>=98) memsleep=99. variable labels memsleep 'Number of members per sleeping room'. value labels memsleep 0 'Less than 1 per room'. formats memsleep (f2.0). missing values memsleep (99). * Compute urban and rural variables coded (1/0) for filters later. compute urban=(QHTYPE = 1). compute rural=(QHTYPE = 2). variable labels urban 'Urban' / rural 'Rural'. value labels urban 1 'Urban' / rural 1 'Rural'. formats urban rural (f1.0). execute. * Check on indicator variable creation. frequencies variables=QHTYPE to domestic. * Toilet facility by shared/not shared. crosstabs /tables=QH109 by QH110. frequencies variables= QH100_1 QH100_2 QH100_3 QH100_4 QH100_5 QH100_6 QH101_11 QH101_12 QH101_21 QH101_31 QH101_41 QH101_51 QH101_96 QH109_11 QH109_12 QH109_13 QH109_21 QH109_22 QH109_23 QH109_61 QH109_96 QH113_1 QH113_2 QH113_3 QH113_4 QH113_95 QH113_96 QH115A QH120A QH121A QH121B QH121C QH121D QH121E QH121F QH121G QH121H QH121I QH121J QH121K QH121L QH121M QH121N QH121AA QH122A QH122B QH122D QH123 QH123A QH142_11 QH142_31 QH142_32 QH142_33 QH142_34 QH142_96 QH143_21 QH143_22 QH143_31 QH143_32 QH143_96 QH144_21 QH144_22 QH144_31 QH144_32 QH144_33 QH144_34 QH144_35 QH144_96 DOMESTIC HOUSE LAND memsleep . * Turn off weights before all factor analysis. weight off. * Name the dataset window for the HH data for use later. dataset name assets. save outfile='assets-revised.sav'. *** Test Factor Analysis. filter off. execute. * Removed qh101_96, qh109_96, domestic due to zero cases, factor /variables QH100_1 QH100_2 QH100_3 QH100_4 QH100_5 QH100_6 QH101_11 QH101_12 QH101_21 QH101_31 QH101_41 QH101_51 QH109_11 QH109_12 QH109_13 QH109_21 QH109_22 QH109_23 QH109_61 QH113_1 QH113_2 QH113_3 QH113_4 QH113_95 QH113_96 QH115A QH120A QH121A QH121B QH121C QH121D QH121E QH121F QH121G QH121H QH121I QH121J QH121K QH121L QH121M QH121N QH121AA QH122A QH122B QH122D QH123 QH123A QH142_11 QH142_31 QH142_32 QH142_33 QH142_34 QH142_96 QH143_21 QH143_22 QH143_31 QH143_32 QH143_96 QH144_21 QH144_22 QH144_31 QH144_32 QH144_33 QH144_34 QH144_35 QH144_96 HOUSE LAND memsleep /missing meansub /analysis QH100_1 QH100_2 QH100_3 QH100_4 QH100_5 QH100_6 QH101_11 QH101_12 QH101_21 QH101_31 QH101_41 QH101_51 QH109_11 QH109_12 QH109_13 QH109_21 QH109_22 QH109_23 QH109_61 QH113_1 QH113_2 QH113_3 QH113_4 QH113_95 QH113_96 QH115A QH120A QH121A QH121B QH121C QH121D QH121E QH121F QH121G QH121H QH121I QH121J QH121K QH121L QH121M QH121N QH121AA QH122A QH122B QH122D QH123 QH123A QH142_11 QH142_31 QH142_32 QH142_33 QH142_34 QH142_96 QH143_21 QH143_22 QH143_31 QH143_32 QH143_96 QH144_21 QH144_22 QH144_31 QH144_32 QH144_33 QH144_34 QH144_35 QH144_96 HOUSE LAND memsleep /print univariate initial extraction /criteria factors(1) iterate(25) /extraction pc /rotation norotate /method=correlation. *** Common Factor analysis ***. ** Removed area-specific variables **. ** Agricultural animal variables excluded ** Land area excluded ** Any others ?. *** Common Factor Analysis. filter off. execute. factor /variables QH100_1 QH100_2 QH100_3 QH100_4 QH100_5 QH100_6 QH101_11 QH101_12 QH101_21 QH101_31 QH101_41 QH101_51 QH109_11 QH109_12 QH109_13 QH109_21 QH109_22 QH109_23 QH109_61 QH113_1 QH113_2 QH113_3 QH113_4 QH113_95 QH113_96 QH115A QH120A QH121A QH121B QH121C QH121D QH121E QH121F QH121G QH121H QH121I QH121J QH121K QH121L QH121M QH121N QH121AA QH122A QH122B QH122D QH123 QH123A QH142_11 QH142_31 QH142_32 QH142_33 QH142_34 QH142_96 QH143_21 QH143_22 QH143_31 QH143_32 QH143_96 QH144_21 QH144_22 QH144_31 QH144_32 QH144_33 QH144_34 QH144_35 QH144_96 HOUSE LAND memsleep /missing meansub /analysis QH100_1 QH100_2 QH100_3 QH100_4 QH100_5 QH100_6 QH101_11 QH101_12 QH101_21 QH101_31 QH101_41 QH101_51 QH109_11 QH109_12 QH109_13 QH109_21 QH109_22 QH109_23 QH109_61 QH113_1 QH113_2 QH113_3 QH113_4 QH113_95 QH113_96 QH115A QH120A QH121A QH121B QH121C QH121D QH121E QH121F QH121G QH121H QH121I QH121J QH121K QH121L QH121M QH121N QH121AA QH122A QH122B QH122D QH123 QH123A QH142_11 QH142_31 QH142_32 QH142_33 QH142_34 QH142_96 QH143_21 QH143_22 QH143_31 QH143_32 QH143_96 QH144_21 QH144_22 QH144_31 QH144_32 QH144_33 QH144_34 QH144_35 QH144_96 HOUSE LAND memsleep /print univariate initial extraction fscore /criteria factors(1) iterate(25) /extraction pc /rotation norotate /save reg(ALL com) /method=correlation. *** Urban Factor Analysis. filter off. filter by urban. execute. factor /variables QH100_1 QH100_2 QH100_3 QH100_4 QH100_5 QH100_6 QH101_11 QH101_12 QH101_21 QH101_31 QH101_41 QH101_51 QH109_11 QH109_12 QH109_13 QH109_21 QH109_22 QH109_23 QH109_61 QH113_1 QH113_2 QH113_3 QH113_4 QH113_95 QH113_96 QH115A QH120A QH121A QH121B QH121C QH121D QH121E QH121F QH121G QH121H QH121I QH121J QH121K QH121L QH121M QH121N QH121AA QH122A QH122B QH122D QH123 QH123A QH142_11 QH142_31 QH142_32 QH142_33 QH142_34 QH142_96 QH143_21 QH143_22 QH143_31 QH143_32 QH143_96 QH144_21 QH144_22 QH144_31 QH144_32 QH144_33 QH144_34 QH144_35 QH144_96 HOUSE LAND memsleep /missing meansub /analysis QH100_1 QH100_2 QH100_3 QH100_4 QH100_5 QH100_6 QH101_11 QH101_12 QH101_21 QH101_31 QH101_41 QH101_51 QH109_11 QH109_12 QH109_13 QH109_21 QH109_22 QH109_23 QH109_61 QH113_1 QH113_2 QH113_3 QH113_4 QH113_95 QH113_96 QH115A QH120A QH121A QH121B QH121C QH121D QH121E QH121F QH121G QH121H QH121I QH121J QH121K QH121L QH121M QH121N QH121AA QH122A QH122B QH122D QH123 QH123A QH142_11 QH142_31 QH142_32 QH142_33 QH142_34 QH142_96 QH143_21 QH143_22 QH143_31 QH143_32 QH143_96 QH144_21 QH144_22 QH144_31 QH144_32 QH144_33 QH144_34 QH144_35 QH144_96 HOUSE LAND memsleep /print univariate initial extraction fscore /criteria factors(1) iterate(25) /extraction pc /rotation norotate /save reg(ALL urb) /method=correlation. *** Rural Factor Analysis. filter off. filter by rural. execute. * removed qh113_96, qh142_96 . factor /variables QH100_1 QH100_2 QH100_3 QH100_4 QH100_5 QH100_6 QH101_11 QH101_12 QH101_21 QH101_31 QH101_41 QH101_51 QH109_11 QH109_12 QH109_13 QH109_21 QH109_22 QH109_23 QH109_61 QH113_1 QH113_2 QH113_3 QH113_4 QH113_95 QH115A QH120A QH121A QH121B QH121C QH121D QH121E QH121F QH121G QH121H QH121I QH121J QH121K QH121L QH121M QH121N QH121AA QH122A QH122B QH122D QH123 QH123A QH142_11 QH142_31 QH142_32 QH142_33 QH142_34 QH143_21 QH143_22 QH143_31 QH143_32 QH143_96 QH144_21 QH144_22 QH144_31 QH144_32 QH144_33 QH144_34 QH144_35 QH144_96 HOUSE LAND memsleep /missing meansub /analysis QH100_1 QH100_2 QH100_3 QH100_4 QH100_5 QH100_6 QH101_11 QH101_12 QH101_21 QH101_31 QH101_41 QH101_51 QH109_11 QH109_12 QH109_13 QH109_21 QH109_22 QH109_23 QH109_61 QH113_1 QH113_2 QH113_3 QH113_4 QH113_95 QH115A QH120A QH121A QH121B QH121C QH121D QH121E QH121F QH121G QH121H QH121I QH121J QH121K QH121L QH121M QH121N QH121AA QH122A QH122B QH122D QH123 QH123A QH142_11 QH142_31 QH142_32 QH142_33 QH142_34 QH143_21 QH143_22 QH143_31 QH143_32 QH143_96 QH144_21 QH144_22 QH144_31 QH144_32 QH144_33 QH144_34 QH144_35 QH144_96 HOUSE LAND memsleep /print univariate initial extraction fscore /criteria factors(1) iterate(25) /extraction pc /rotation norotate /save reg(ALL rur) /method=correlation. * Label the created score variables. rename variables (com1 urb1 rur1=comscore urbscore rurscore). variable labels comscore 'Common wealth score' /urbscore 'Urban wealth score' /rurscore 'Rural wealth score'. * Add a variable used for linking later. filter off. string rowtype_ (A8). compute rowtype_ = 'EST'. * Calculate regressions. ** Area=urban. filter off. filter by urban. execute. * Declare a dataset to be written to in the regression. dataset declare urbancorv. * Run regression of comscore with urbscore. regression /missing listwise /statistics coeff outs R anova /criteria=pin(.05) pout(.10) /noorigin /dependent comscore /method=enter urbscore /outfile=corv(urbancorv). * Activate file of output from regression. dataset activate urbancorv. * Drop all rows of output except the coefficients. select if (rowtype_ = 'EST'). execute. * Delete unnecessary variables before merging. delete variables DEPVAR_ VARNAME_. * Rename variables containing the constant and the coefficient. rename variables CONST_=urbconst urbscore=urbcoeff. * Re-activate the main household data. dataset activate assets. * merge the coefficients. match files /file = * /table = urbancorv /by ROWTYPE_. execute. * Calculate regressions. ** Area=rural. filter off. filter by rural. execute. * Declare a dataset to be written to in the regression. dataset declare ruralcorv. * Run regression of comscore with rurscore. regression /missing listwise /statistics coeff outs R anova /criteria=pin(.05) pout(.10) /noorigin /dependent comscore /method=enter rurscore /outfile=corv(ruralcorv). * Activate file of output from regression. dataset activate ruralcorv. * Drop all rows of output except the coefficients. select if (rowtype_ = 'EST'). execute. * Delete unnecessary variables before merging. delete variables DEPVAR_ VARNAME_. * Rename variables containing the constant and the coefficient. rename variables CONST_=rurconst rurscore=rurcoeff. * Re-activate the main household data. dataset activate assets. * merge the coefficients. match files /file = * /table = ruralcorv /by ROWTYPE_. execute. dataset close urbancorv. dataset close ruralcorv. dataset activate assets. filter off. *** Calculate combined wealth score from Urban and Rural Scores. * Use coefficients from urban and rural regressions above. compute combscor=0. print formats combscor (f11.5). write formats combscor (f11.5). ** Urban. if (urban = 1) combscor=urbconst+urbcoeff*urbscore. ** Rural. if (rural = 1) combscor=rurconst+rurcoeff*rurscore. variable labels combscor 'Combined national wealth score'. execute. compute hhwt = QHWEIGHT/1000000. variable labels hhwt 'HH weights'. formats hhwt (f12.6). weight by hhwt. filter off. execute. frequencies variables=combscor comscore /format=notable /ntiles=5 /statistics=minimum maximum stddev mean /histogram normal /order=analysis. filter off. filter by urban. execute. frequencies variables=combscor urbscore /format=notable /ntiles=5 /statistics=minimum maximum stddev mean /histogram normal /order=analysis. filter off. filter by rural. execute. frequencies variables=combscor rurscore /format=notable /ntiles=5 /statistics=minimum maximum stddev mean /histogram normal /order=analysis. filter off. execute. *Calculate quintiles and scores for data file. compute hhmemwt=QHWEIGHT*hhusual/1000000. variable labels hhmemwt 'HH members weighting for index'. formats hhmemwt (f12.6). weight by hhmemwt. filter off. filter by urban. execute. rank variables=urbscore (A) /rank /ntiles (5) /print=yes /ties=mean. filter off. filter by rural. execute. rank variables=rurscore (A) /rank /ntiles (5) /print=yes /ties=mean. filter off. execute. rank variables=combscor (A) /rank /ntiles (5) /print=yes /ties=mean. variable labels ncombsco 'Combined wealth index' /nurbscor 'Urban wealth index' /nrurscor 'Rural wealth index'. value labels ncombsco nurbscor nrurscor 1 'Lowest' 2 'Second' 3 'Middle' 4 'Fourth' 5 'Highest'. *** Check on quintiles. frequencies variables=ncombsco nurbscor nrurscor. weight by hhwt. ctables /table ( QH100_1+QH100_2+QH100_3+QH100_4+QH100_5+QH100_6+ QH101_11+QH101_12+QH101_21+QH101_31+QH101_41+QH101_51+ QH109_11+QH109_12+QH109_13+QH109_21+QH109_22+QH109_23+QH109_61+ QH113_1+QH113_2+QH113_3+QH113_4+QH113_95+QH113_96+ QH115A+QH120A+QH121A+QH121B+QH121C+QH121D+QH121E+QH121F+QH121G+QH121H+QH121I+QH121J+QH121K+QH121L+QH121M+QH121N+QH121AA+QH122A+QH122B+QH122D+QH123+QH123A+ QH142_11+QH142_31+QH142_32+QH142_33+QH142_34+QH142_96+ QH143_21+QH143_22+QH143_31+QH143_32+QH143_96+ QH144_21+QH144_22+QH144_31+QH144_32+QH144_33+QH144_34+QH144_35+QH144_96+ HOUSE+LAND+memsleep )[S][Mean F8.3] by (ncombsco+nurbscor+nrurscor)[C] /slabels visible=no. * Alternative instead of ctables. *means tables= QH100_1 QH100_2 QH100_3 QH100_4 QH100_5 QH100_6 QH101_11 QH101_12 QH101_21 QH101_31 QH101_41 QH101_51 QH109_11 QH109_12 QH109_13 QH109_21 QH109_22 QH109_23 QH109_61 QH113_1 QH113_2 QH113_3 QH113_4 QH113_95 QH113_96 QH115A QH120A QH121A QH121B QH121C QH121D QH121E QH121F QH121G QH121H QH121I QH121J QH121K QH121L QH121M QH121N QH121AA QH122A QH122B QH122D QH123 QH123A QH142_11 QH142_31 QH142_32 QH142_33 QH142_34 QH142_96 QH143_21 QH143_22 QH143_31 QH143_32 QH143_96 QH144_21 QH144_22 QH144_31 QH144_32 QH144_33 QH144_34 QH144_35 QH144_96 HOUSE LAND memsleep by ncombsco nurbscor nrurscor /cells mean count stddev. graph /histogram(normal)=combscor /title= 'Distribution of Households by Wealth Scores'. frequencies variables=combscor /format=notable /ntiles=5 /statistics=stddev minimum maximum semean mean median mode skewness seskew kurtosis sekurt /order=analysis. weight off. filter off. write formats combscor urbscore rurscore (f11.5). * Save final dataset of assets. save outfile='assets-revised.sav'. *** Write out scores file. write outfile='scores-revised.dat' table /QHCLUST QHNUMBER combscor ncombsco urbscore nurbscor rurscore nrurscor. execute. * Produce table 2.5 weighted by de jure population to test. weight by hhmemwt. compute total = 0. variable labels total 'Total'. value labels total 0 ' '. ctables /vlabels variables=QHTYPE QHREGION total Ncombsco display=both /table QHTYPE [C] + QHREGION [C] + total [C] BY Ncombsco [C][rowpct.count '%' F8.1, totals [rowpct.count '%' F8.1, count '' F8.0]] /categories variables=Ncombsco total=yes /titles title='Table 2.6 Wealth Quintiles' '' 'Percent distribution of the de jure population by wealth quintiles, according to residence and region, Jordan DHS 2017-18' corner='Residence/region' /slabels visible=no.